package com.jiuqi.muchmore.clothing.view.keyboard.adapter;

import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.BaseAdapter;
import android.widget.EditText;

import com.jiuqi.muchmore.clothing.view.keyboard.MMCKeyboard;

public abstract class KeyboardGridViewAdapter<T> extends BaseAdapter{

	public static interface DataChangeCallBack {
		public void afterChanged(Object o);
	}
	
	protected class ItemClickListener implements OnClickListener{
		private String title;
		public ItemClickListener(String title){
			this.title = title;
		}

		@Override
		public void onClick(View v){
			kbEditText.setText(title);
			mmckeyboard.doFinish();
		}
	}
	
	protected LayoutInflater inflater;
	protected Context context;
	protected EditText kbEditText;
	protected MMCKeyboard mmckeyboard;
	protected DataChangeCallBack dataChangeCallBack;
	public DataChangeCallBack getDataChangeCallBack(){
    	return dataChangeCallBack;
    }

	public void setDataChangeCallBack(DataChangeCallBack dataChangeCallBack){
    	this.dataChangeCallBack = dataChangeCallBack;
    }

	public void setKbEditText(EditText kbEditText){
    	this.kbEditText = kbEditText;
    }

	public void setMmckeyboard(MMCKeyboard mmckeyboard){
    	this.mmckeyboard = mmckeyboard;
    }

	protected abstract List<T> getItemList();
	
	public abstract void refreshListData();
	
	public KeyboardGridViewAdapter(Context context) {
		this.context = context;
		inflater = LayoutInflater.from(context);
	}
	
	public int getCount(){
		return getItemList().size();
	}
}
